function [B_X, B_Y, player_distances, player_angles] = FeaturesToState(features)
        
    % feature vector variables
    global x_tiles;
    global y_tiles; 
    global x_tile_width;
    global y_tile_width;
    global angle_tiles;
    global angle_tile_width;
    global distance_tiles;
    global distance_tile_width;
    global num_tilings;
    
    global num_players_r;
    global num_players_b;

    distances_vec = {0 0 0 0 0 0 0 0 0 0};
    angles_vec = {0 0 0 0 0 0 0 0 0 0};
    
    ball_x = features(1:num_tilings);
    offset = num_tilings*(x_tiles+1) - 1;
    
    ball_y = features((num_tilings+1):(2*num_tilings)) - offset;
    offset = offset + num_tilings*(y_tiles+1) - 1;

    for i = 1:(num_players_r+num_players_b)
        d_tilings = (1+i);
        distances_vec{i} = features((d_tilings*num_tilings+1):((d_tilings+1)*num_tilings)) - offset;
        offset = offset + num_tilings*(distance_tiles+1) - 1;

        a_tilings = (1+num_players_r + num_players_b + i);
        angles_vec{i} = features((a_tilings*num_tilings+1):((a_tilings+1)*num_tilings)) - offset;
        offset = offset + num_tilings*(angle_tiles+1) - 1;

    end
    
    B_X = ReverseFeatures(ball_x, num_tilings, x_tiles, x_tile_width);
    B_Y = ReverseFeatures(ball_y, num_tilings, y_tiles, y_tile_width);

    for i = 1:(num_players_r + num_players_b) 
       player_distances(i) = ReverseFeatures(distances_vec{i}, num_tilings, distance_tiles, distance_tile_width); 
       player_angles(i) = ceil((ReverseFeatures(angles_vec{i}, num_tilings, angle_tiles, angle_tile_width)/45))*45;
    end
    %S = [ball_x, ball_y, distances_vec{1:(num_players_r+num_players_b)}, angles_vec{1:(num_players_r+num_players_b)}];

end